<?php

use Hyn\Tenancy\Environment;

if (!function_exists("tenant")) {
    function tenant()
    {
        $tenancy = app(Environment::class);
        return $tenancy->tenant();
    }
}

if (!function_exists("tenantDomain")) {
    function tenantDomain()
    {

        return app(Environment::class)->hostname()->fqdn;
    }
}

if (!function_exists("get")) {
    function get($object, $express, $default = null)
    {
        if (!isset($object) || !isset($express)) {
            return $default;
        }
        $paths = explode(".", $express);
        $attr = array_shift($paths);
        if (!isset($object[$attr])) {
            return $default;
        }
        $value = $object[$attr];
        if (count($paths) == 0) {
            return $value;
        }
        return get($value, implode(".", $paths), $default);

    }
}

